package com.blb.ioc;

import com.blb.ioc.myspring.MyComponent;
import com.blb.ioc.myspring.Myvalue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MyComputer {
    @Myvalue(value = "外星人")
    private String brand;
    @MyComponent(type=IntelCpu.class)
    private Cpu cpu;
    @MyComponent(type= KingstonMemory.class)
    private Memory memory;

    public MyComputer() {
    }

    public MyComputer(String brand, Cpu cpu, Memory memory) {
        this.brand = brand;
        this.cpu = cpu;
        this.memory = memory;
    }

    public void start(){
        System.out.println(this.brand+"电脑启动了");
        this.cpu.run();
        this.memory.read();
        this.memory.write();


    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public Cpu getCpu() {
        return cpu;
    }

    public void setCpu(Cpu cpu) {
        this.cpu = cpu;
    }

    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }
}
